var domContainer = document.querySelector('.container');

var imgWidth = 200;
var spaceWidth = 10;
var containerWidth = domContainer.offsetWidth;
var imgArr = [];
var colsArr;

function init() {
  initData();
  initSize();
}

function initData() {
  for (var i = 0; i < 41; i++) {
    imgArr.push('img/' + i + '.jpg');
  }
}

function initSize() {
  console.log(containerWidth);
  var cols = Math.floor(containerWidth / imgWidth);
  console.log(cols);
  spaceWidth = Math.floor((containerWidth - cols * imgWidth) / (cols + 1));
  console.log(spaceWidth);
  colsArr = new Array(cols);
  console.log(colsArr.length);

  for (var i = 0; i < cols; i++) {
    var itemdiv = document.createElement('div');
    itemdiv.style.width = imgWidth + 'px';
    itemdiv.style.marginLeft = spaceWidth + 'px';
    itemdiv.className = 'itemdiv';
    domContainer.appendChild(itemdiv);
  }
}

function insertSingleImg(imgUrl) {
  var img = document.createElement('img');
  img.src = imgUrl;
  domContainer.appendChild(img);
}

function get

init();
